package net.caixiaomi.info.adapter;

import android.support.annotation.LayoutRes;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;

import net.caixiaomi.info.R;
import net.caixiaomi.info.app.CommonApp;
import net.caixiaomi.info.base.quickadapter.BaseQuickAdapter;
import net.caixiaomi.info.base.quickadapter.BaseViewHolder;
import net.caixiaomi.info.model.ManagerCardModel;

import java.util.List;

import static net.caixiaomi.info.service.DownLoadService.url;

/**
 * 管理银行卡适配器
 */

public class ManagerCardAdapter extends BaseQuickAdapter<ManagerCardModel, BaseViewHolder> {
    public ManagerCardAdapter(@LayoutRes int layoutResId, List<ManagerCardModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ManagerCardModel item) {
        try {
            helper.setText(net.caixiaomi.info.R.id.name, item.getBankName());
            helper.setText(net.caixiaomi.info.R.id.card, item.getCardNo());
            helper.getView(net.caixiaomi.info.R.id.selected).setSelected(TextUtils.equals("1", item.getStatus()));
            helper.addOnClickListener(net.caixiaomi.info.R.id.btn_close);
            helper.addOnClickListener(net.caixiaomi.info.R.id.selected);
            if (helper.getAdapterPosition() != 0) {
                helper.getView(net.caixiaomi.info.R.id.container).setPadding((int) CommonApp.getInstance().getResources().getDimension(net.caixiaomi.info.R.dimen.padding_12), 0, (int) CommonApp.getInstance().getResources().getDimension(net.caixiaomi.info.R.dimen.padding_12), (int) CommonApp.getInstance().getResources().getDimension(net.caixiaomi.info.R.dimen.padding_12));
            }
            ImageView imgView=helper.getView(R.id.card_img);
//            RequestOptions requestOptions = RequestOptions.circleCropTransform();
//            Glide.with(imgView.getContext()).load(item.getBankLogo()).apply(requestOptions).into(imgView);
            Glide.with(imgView.getContext()).load(item.getBankLogo()).into(imgView);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
